<template>
  <div>
      <h1>当前求和为:{{sum}}</h1>
      <select >
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
      </select>&nbsp;
      <button @click="increment">点我奇数加一</button>&nbsp;
      <button @click="decrement">点我减一</button>&nbsp;
      <button @click="incrementOdd">点我奇数加一</button>&nbsp;
      <button @click="incrementWait">点我延时500ms加一</button>
  </div>
</template>

<script>
export default {
    name:'Count',
    data(){
       return{
            sum:0
       }
    },
    methods:{
        increment(){
            this.sum += 1
        },
        decrement(){
            this.sum -= 1
        },
        incrementOdd(){
            if(this.sum %2 === 1){
                this.sum += 1
            }
        },
        incrementWait(){
            setTimeout(()=>{
                this.sum += 1
            },500)
        },
    }
}
</script>

<style>

</style>